home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / flxkey.exe / FLXKEY.DOC < prev    next >
Text File  |  1993-02-21  |  31KB  |  933 lines

  1.  
  2.  
  3.  
  4.                       FlxKey 1.1  :  Registration-key Unit
  5.                       for Borland's Turbo Pascal 4.0 - 7.0
  6.  
  7.                        Copyright (c) 1993, Guy McLoughlin
  8.                               All rights reserved.
  9.  
  10.                          Released as Shareware, 22/02/93.
  11.  
  12.  
  13.      DESCRIPTION
  14.      ===========
  15.  
  16.              FlxKey is an easy to use Turbo Pascal unit, that enables
  17.           you to create encrypted user-registration keys for your
  18.           programs.
  19.  
  20.              To make the whole process as "painless" as possible,
  21.           FlxKey performs all the encryption, decryption, and error-
  22.           checking for you.
  23.  
  24.           The FlxKey unit comes pre-compiled in six .TPU files:
  25.  
  26.               FLX40TPU.ZIP  (Turbo Pascal 4.0)
  27.               FLX50TPU.ZIP  (Turbo Pascal 5.0)
  28.               FLX55TPU.ZIP  (Turbo Pascal 5.5)
  29.               FLX60TPU.ZIP  (Turbo Pascal 6.0)
  30.               FLX70TPU.ZIP  (Turbo Pascal 7.0  "real mode"       )
  31.               FLX70TPP.ZIP  (Borland Pascal 7.0  "protected mode")
  32.  
  33.           Also included are several sample programs, each demonstrat-
  34.           ing a different method of using the FlxKey unit.
  35.  
  36.  
  37.      PUTTING FLX TO WORK
  38.      ===================
  39.  
  40.           There are only two routines to call within the FlxKey unit:
  41.  
  42.             CreateFlxKey - Creates an encrypted registration-key
  43.                            based on the data you pass to it.
  44.  
  45.             ReadFlxKey   - Reads/decodes/error-checks an encrypted
  46.                            registration-key, and returns the key's
  47.                            data.
  48.  
  49.           Both of these routines will return an error-code number,
  50.           which your program can use to determine it's best course of
  51.           action.
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                     Page 1
  64.  
  65.  
  66.  
  67.  
  68.      CREATING A REGISTRATION-KEY
  69.      ===========================
  70.  
  71.           Before you can use the CreateFlxKey routine you must:
  72.  
  73.             1- Place the name of the FlxKey unit in your program's
  74.                "uses" declaration.
  75.  
  76.                ie:   uses
  77.                        Crt,
  78.                        FlxKey;
  79.  
  80.  
  81.             2- Declare a "rc_Flx" variable, used to pass the data you
  82.                want to encrypt into the registration key.
  83.  
  84.               (* FlxKey type definitions.                             *)
  85.             type
  86.               st_20  = string[20];
  87.               st_30  = string[30];
  88.               st_254 = string[254];
  89.  
  90.               rc_Flx = record
  91.                          FirstName : st_20;
  92.                          LastName  : st_30;
  93.                          Address1  : st_30;
  94.                          Address2  : st_30;
  95.                          Address3  : st_30;
  96.                          AppName   : st_20;
  97.                          Version   : word;
  98.                          Serial    : longint;
  99.                          Date      : longint;
  100.                          Access    : word;
  101.                          MiscData  : st_254
  102.                        end;
  103.  
  104.               var
  105.                 TempKeyRec : rc_Flx;
  106.  
  107.  
  108.             3- Declare two encryption-code string variables, to be
  109.                used to encrypt the registration key. These strings
  110.                can be from 1 character to 100 characters in length,
  111.                though I would recommend using at least 10 characters
  112.                for each encryption string.
  113.  
  114.                ie:   var
  115.                        Ecode1,
  116.                        Ecode2 : string[100];
  117.  
  118.                or
  119.                      var
  120.                        Ecode1,
  121.                        Ecode2 : st_100;
  122.  
  123.  
  124.  
  125.  
  126.                                     Page 2
  127.  
  128.  
  129.  
  130.  
  131.             4- Declare a word-type variable to hold the error-code
  132.                returned by CreateFlxKey.
  133.  
  134.                ie:   var
  135.                        ErrorCode : word;
  136.  
  137.  
  138.             5- Declare a path/filename string variable, that will be
  139.                used to pass the name of the encrypted registration-
  140.                key file you want to create.
  141.  
  142.                ie:   var
  143.                        RegKeyName : string[79];
  144.  
  145.                 or
  146.                      var
  147.                        RegKeyName : st_79;
  148.  
  149.  
  150.             6- Assign your data to the "rc_Flx" variable.
  151.  
  152.                To assign data to the "TempKeyRec" you declared earlier,
  153.                you could code something like this:
  154.  
  155.               (* TempKeyRec is our "rc_Flx" type variable.            *)
  156.                with TempKeyRec do
  157.                  begin
  158.  
  159.               (* Assign the firstname, lastname, and address of the   *)
  160.               (* user this key is being created for.                  *)
  161.                    FirstName := 'John';
  162.                    LastName  := 'Smith';
  163.                    Address1  := '1234 AnyPlace Road,';
  164.                    Address2  := 'BigCity, BigPlace,';
  165.                    Address3  := 'BigCountry, BigZip';
  166.  
  167.               (* Assign the name of your amazing program that this    *)
  168.               (* key belongs to.                                      *)
  169.                    AppName   := 'Amazing Program';
  170.  
  171.               (* Assign the version number of your program. For       *)
  172.               (* example, the number below could be used to represent *)
  173.               (* version 3.10 of your software.                       *)
  174.                    Version   := 310;
  175.  
  176.               (* Assign the serial number of the registration-key you *)
  177.               (* are creating for this user.                          *)
  178.                    Serial    := 1234567890;
  179.  
  180.               (* This is the date that will be stored in the          *)
  181.               (* encrypted registration-key, in standard Turbo Pascal *)
  182.               (* packed "datetime" format. If you set this variable   *)
  183.               (* to zero, the CreateFlxKey routine will automatically *)
  184.               (* stamp it with the current date/time.                 *)
  185.                    Date      := 0;
  186.  
  187.  
  188.  
  189.                                     Page 3
  190.  
  191.  
  192.  
  193.  
  194.               (* This is the user-access level that you are assigning *)
  195.               (* to this user. From 0 to 65,535.                      *)
  196.                    Access    := 1234;
  197.  
  198.  
  199.               (* This variable is used to store a miscellaneous data  *)
  200.               (* string, which can be from 1..254 characters in long. *)
  201.                    MiscData  := 'You can place what ever sort of data' +
  202.                                  ' you like' + #13#10 + '            ' +
  203.                                  '    within this field, upto 254 ' +
  204.                                  'bytes worth.'
  205.                  end;
  206.  
  207.  
  208.             7- Assign the path/filename to the encrypted registration-
  209.                key you want to create.
  210.  
  211.                ie:   RegKeyName := 'AMAZPROG.KEY';
  212.  
  213.                or
  214.                      RegKeyName := 'C:\AP-KEYS\AMAZPROG.KEY';
  215.  
  216.  
  217.             8- Assign data to the two the two encryption-code strings
  218.                that you want to use to encrypt the registration-key.
  219.                This is a very crucial step in the process, that will
  220.                be covered in more detail when we look at "embedding"
  221.                random encryption-codes into your programs.
  222.  
  223.                For now we will assign two simple encryption-code
  224.                strings, to be used for demonstration purposes.
  225.  
  226.                ie:   Ecode1 := 'Apple';
  227.                      Ecode2 := 'Orange';
  228.  
  229.              Now that you've created all the variables necessary, and
  230.           assigned data to them, you can call "CreateFlxKey" to create
  231.           the encrypted registration key.
  232.  
  233.                ie:  CreateFlxKey(TempKeyRec, Ecode1, Ecode2,
  234.                                  RegKeyName, ErrorCode);
  235.  
  236.              If this call was successful, the ErrorCode variable should
  237.           be equal to zero, and you should now find a new file on your
  238.           disk called "AMAZPROG.KEY".
  239.  
  240.  
  241.      CHECKING FOR ERRORS
  242.      ===================
  243.  
  244.              Ok, so what happens when the Er